﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;

namespace GameViewer.Core.Archives
{
    public class FileInfo
    {
        public Archive Archive;
        public string FileName;
        public string Path;
        public string BaseName;
        public long CompressedSize;
        public long UnCompressedSize;
    }

    public abstract class Archive
    {
        protected string mType;
        protected string mName;
        protected List<FileInfo> mFiles;

        public Archive(string name, string archType)
        {
            mName = name;
            mType = archType;
            mFiles = new List<FileInfo>();
        }

        public string Name
        {
            get
            {
                return mName;
            }
        }

        public string Type
        {
            get
            {
                return mType;
            }
        }

        public abstract void Load();

        public abstract System.IO.Stream Open(string fileName);

        public List<FileInfo> FileInfos
        {
            get
            {
                return mFiles;
            }
        }

        public List<FileInfo> FindFileInfo(string pattern)
        {
            Regex reg = new Regex(pattern);
            return mFiles.FindAll(delegate(FileInfo file)
            {
                return reg.IsMatch(file.FileName);
            });
        }
    }
}
